package com.crm.swagger.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

@Component
@Primary
public class SwaggerConfig implements SwaggerResourcesProvider {

    @Override
    public List<SwaggerResource> get() {

        List<SwaggerResource> resources = new ArrayList<>();

        /**
         *  系统设置 ---> swagger页面显示服务的名字
         *  /api/crm-systemset/v2/api-docs ---> /api/systemset就是网关转发到具体路由的路径，
         *  后面的/v2/api-docs是swagger的资源路径，固定写法
         */
        resources.add(swaggerResource("系统设置", "/api/system-set/v2/api-docs", "2.0"));
        resources.add(swaggerResource("基础数据", "/api/base-data/v2/api-docs", "2.0"));
        resources.add(swaggerResource("客户管理", "/api/customer-manager/v2/api-docs", "2.0"));
        resources.add(swaggerResource("服务管理", "/api/service-manager/v2/api-docs", "2.0"));
        resources.add(swaggerResource("营销管理", "/api/marketing-manager/v2/api-docs", "2.0"));
        return resources;
    }


    private SwaggerResource swaggerResource(String name, String location, String version) {

        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}